package algame;

import algame.Game;
import java.io.InputStream;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry;


public class Loader {

	public static void extractLibs() {
		InputStream is = Loader.class.getResourceAsStream("native.zip");
		ZipInputStream zis = new ZipInputStream(is);
//		ZipEntry entry;
//		String curdir = ClassLoader.getSystemClassLoader().getResource(".").getPath();

		try {
//			while ((entry = zis.getNextEntry()) != null) {
				// do something with the entry - for example, extract the data
//				System.out.println("Copia " + entry.getName() + " in " + curdir + "/algame/");
//			}
		} catch (Exception e) {
		}
	}

	public static void main(String[] argv) {
		System.out.println("SO: " + System.getProperty("os.name"));
		if(isWindows()) { System.setProperty("java.library.path", "native/windows"); }
		if(isMac()) { System.setProperty("java.library.path", "native/macosx"); }
		if(isUnix()) { System.setProperty("java.library.path", "native/linux"); }
		if(isSolaris()) { System.setProperty("java.library.path", "native/solaris"); }
//		extractLibs();
		Game game = new Game();
		game.start();
	}

	public static boolean isWindows() {

		String os = System.getProperty("os.name").toLowerCase();
		// windows
		return (os.indexOf("win") >= 0);

	}

	public static boolean isMac() {

		String os = System.getProperty("os.name").toLowerCase();
		// Mac
		return (os.indexOf("mac") >= 0);

	}

	public static boolean isUnix() {

		String os = System.getProperty("os.name").toLowerCase();
		// linux or unix
		return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0);

	}

	public static boolean isSolaris() {

		String os = System.getProperty("os.name").toLowerCase();
		// Solaris
		return (os.indexOf("sunos") >= 0);

	}

}
